use threads;    my $a : shared = 4; 
my $b : shared = "foo"; 
my $thr1 = threads->new(sub { 
    lock($a); 
    threads->yield; 
    sleep 20; 
    lock($b); 
}); 
my $thr2 = threads->new(sub { 
    lock($b); 
    threads->yield; 
    sleep 20; 
    lock($a); 
});

$thr1->join();
$thr2->join();
